import axios from './index'

const preUrl = 'manager'


// 获取部门列表
const getDepartmentList = {
  p: [`get,/department`],
  r: params => {
    return axios.get(`${preUrl}/department`, {
      params
    })
  }
}


// 获取部门列表
const getProjectType = {
  p: [`get,/type`],
  r: () => {
    return axios.get(`${preUrl}/type`)
  }
}

// 获取项目列表
const getProjectList = {
  p: [`get,/project`],
  r: params => {
    return axios.get(`${preUrl}/project`, {
      params
    })
  }
}

// 获取公众号列表
const getAreaList = {
  p: [`get,/area`],
  r: params => {
    return axios.get(`${preUrl}/area`, {
      params
    })
  }
}


// 新增项目
const addProject = {
  p: [`post,/newProject`],
  r: params => {
    return axios.post(`${preUrl}/newProject`, params)
  }
}

// 新增部门
const addDepartment = {
  p: [`post,/newDepartment`],
  r: params => {
    return axios.post(`${preUrl}/newDepartment`, params)
  }
}

// 新增部门
const addArea = {
  p: [`post,/newArea`],
  r: params => {
    return axios.post(`${preUrl}/newArea`, params)
  }
}

// 删除部门
const delDepartment = {
  p: [`delete,/deleteDepartment`],
  r: params => {
    return axios.delete(`${preUrl}/deleteDepartment/${params.id}`)
  }
}


// 删除项目
const delProject = {
  p: [`delete,/deleteProject`],
  r: params => {
    return axios.delete(`${preUrl}/deleteProject/${params.id}`)
  }
}

// 删除项目
const delArea = {
  p: [`delete,/deleteArea`],
  r: params => {
    return axios.delete(`${preUrl}/deleteArea/${params.id}`)
  }
}


// 编辑项目
const editProject = {
  p: [`put,/updateProject`],
  r: params => {
    return axios.put(`${preUrl}/updateProject`, params)
  }
}

// 编辑部门
const editDepartment = {
  p: [`put,/updateDepartment`],
  r: params => {
    return axios.put(`${preUrl}/updateDepartment`, params)
  }
}

// 编辑部门
const editArea = {
  p: [`put,/updateDepartment`],
  r: params => {
    return axios.put(`${preUrl}/updateArea`, params)
  }
}


export {
  getProjectList,
  getProjectType,
  getDepartmentList,
  getAreaList,
  addDepartment,
  addProject,
  addArea,
  editDepartment,
  editProject,
  editArea,
  delDepartment,
  delProject,
  delArea
}